package com.sourceQ.system.mq.sms.consumer;

import com.sourceQ.system.mq.sms.vo.SmsSendMessage;
import com.sourceQ.system.service.message.sms.SmsSendService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author: SourceQ
 * @create: 2024-04-18 20:35
 * @Description:sms消息监听器（消费者）
 */
@Component
@Slf4j
public class SmsSendConsumer {
    @Autowired
    private SmsSendService smsSendService;
    @EventListener
    @Async // Spring Event 默认在 Producer 发送的线程，通过 @Async 实现异步
    public void onMessage(SmsSendMessage message) {
        log.info("[onMessage][消息内容({})]", message);
        smsSendService.doSendSms(message);
    }

}
